Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Unexpected token "=" reported while running eslint on arrow functions

I have a JavaScript class and inside it I have an async method which looks like below.

class ABC {
    func = async () => { //----line 10
        //some code
    }
    func2 = () => { //----line 11
        //some code 
    }
}

When I run ESLint it's reporting one error. The application itself is working as expected.

unexpected token '=' at line 10 (& 11)

eslintrc.json

{
   "env":{
       "es2021":true
    }
}

What do I need to do in order to get rid of these lint errors and still keep these methods as arrow functions?

ESLint version: eslint :"^7.32.0"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Upgrade to ESLint 8 and add this setting to your .eslintrc:

"parserOptions": {
  "ecmaVersion": 2022
}

Reason: you are using class fields. Support for class fields syntax in ESLint has been introduced with version 8.

Note that the specification of class fields, although already finalized in April 2021, will be published with ECMAScript 2022, expected next year.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!